// tombstone.txt - This very simple script waits until this object is searched. When it
// is, displays a tombstone message.  Assumes it's associated with a tombstone...

// Memory Cells - 
//   0 - Tombstone message to display (0 - 15).
//

beginterrainscript;

variables;

short msgv, choice;
string msg1, msg2;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
	msgv = get_memory_cell(0);

	// set first string
	clear_buffer();
	if (msgv == 0) {
		append_string("Here lies brother T'sober");
	}
	else if (msgv == 1) {
		append_string("John Smith");
	}
	else if (msgv == 2) {
		append_string("Sister Jane");
	}
	else if (msgv == 3) {
		append_string("Bob");
	}
	else if (msgv == 4) {
		append_string("Father Thyme");
	}
	else if (msgv == 5) {
		append_string("Homer S.");
	}
	else if (msgv == 6) {
		append_string("Sarah P.");
	}
	else if (msgv == 7) {
		append_string("Wint Green");
	}
	else if (msgv == 8) {
		append_string("Peter P.");
	}
	else if (msgv == 9) {
		append_string("April May");
	}
	else if (msgv == 10) {
		append_string("David");
	}
	else if (msgv == 11) {
		append_string("Honey Money");
	}
	else if (msgv == 12) {
		append_string("James");
	}
	else if (msgv == 13) {
		append_string("Walter R.");
	}
	else if (msgv == 14) {
		append_string("Unknown (John Doe)");
	}
	else { // msgv >= 15
		append_string("Wesley W.");
	}
	get_buffer_text(msg1);
	// set second string
	clear_buffer();
	if (msgv == 0) {
		append_string("May he rest in peace");
	}
	else if (msgv == 1) {
		append_string("Left the world way too soon");
	}
	else if (msgv == 2) {
		append_string("Defender till the end");
	}
	else if (msgv == 3) {
		append_string("Stay porous dude");
	}
	else if (msgv == 4) {
		append_string("Great scheduler - will be missed");
	}
	else if (msgv == 5) {
		append_string("D'oh!");
	}
	else if (msgv == 6) {
		append_string("Your farsight was the best");
	}
	else if (msgv == 7) {
		append_string("Best breath ever");
	}
	else if (msgv == 8) {
		append_string("You'll never grow up");
	}
	else if (msgv == 9) {
		append_string("At least March is behind you");
	}
	else if (msgv == 10) {
		append_string("The deeds you performed in life will outlive you");
	}
	else if (msgv == 11) {
		append_string("In death, as in life, the best of both worlds");
	}
	else if (msgv == 12) {
		append_string("A boy with a sense of duty");
	}
	else if (msgv == 13) {
		append_string("Great healer and comforter");
	}
	else if (msgv == 14) {
		append_string("Died protecting the staff");
	}
	else { // msgv >= 15
		append_string("Keep popping on");
	}
	get_buffer_text(msg2);
	message_dialog(msg1, msg2);

	if ((get_flag(50, 0) > 0) && (get_flag(51, 0) == 0) && (msgv == 14)) {
		reset_dialog();
		add_dialog_str(0, "This gravestone seems out of place amongst the others.", 0);
		if (has_item(318)) {
			add_dialog_str(1, "You could do a thorough search using the shovel you have.", 0);
			add_dialog_choice(0, "Leave alone");
			add_dialog_choice(1, "Dig it up");
		}
		else {
			add_dialog_str(1, "You don't have anything in hand to do more than a cursory search.", 0);
			add_dialog_str(2, "You find nothing.", 0);
			add_dialog_choice(0, "Ok");
		}
		choice = run_dialog(FALSE);
		if (choice == 2) {
			set_flag(51, 0, 1);
			play_sound(79);
			message_dialog("As you dig into the grave, your shovel hits something, not very far down.",
					"You pick up the staff piece from the dirt, then restore the grave to its previous state.");
			change_spec_item(1, 1);
		}
	}
break;
